/**
 * 
 */
package com.example.radioclub.utilities;

import com.example.radioclub.data.Constants;
import com.example.radioclub.data.Enumerations;
import com.example.radioclub.data.Enumerations.Dir;

/**
 * This class defines some functions for making URLs for some of MelOn API.
 * These URLs are some used in RestTemplate in GET Request.
 * 
 * @author wizard
 * 
 */
public class MelonApiURLsTools {

	public static String getDailyChartURL(int offset, int limit) {
		return Constants.API_MELON_CHART_DAILY + "?offset=" + offset
				+ "&limit=" + limit + "";
	}

	public static String getWeeklyChartURL() {
		return Constants.API_MELON_CHART_WEEKLY;
	}

	public static String getWeeklyChartAtDate(int date, int month, int year) {
		return Constants.API_MELON_CHART_WEEKLY_STARTDATE;
	}

	public static String getWeeklyChartLatestURL(int offset, int limit) {
		return Constants.API_MELON_CHART_WEEKLY_LATEST + "?offset=" + offset
				+ "&limit=" + limit + "";
	}

	public static String getMonthlyChart() {
		return Constants.API_MELON_CHART_MONTHLY;
	}

	public static String getMonthlyChartLatestURL(int offset, int limit) {
		return Constants.API_MELON_CHART_MONTHLY_LATEST + "?offset=" + offset
				+ "&limit=" + limit + "";
	}

	// searching section

	public static String getSearchIntegrationArtist(int offset, int limit,
			String keyword) {
		String o = offset + "", l = limit + "";
		if (offset < 0)
			o = "0";
		if (limit <= 0)
			l = "10";
		return Constants.API_MELON_SEARCH_INTEGRATION_ARTIST + "?offset=" + o
				+ "&limit=" + l + "&keyword=" + keyword;
	}

	public static String getSearchIntegrationSong(int offset, int limit,
			String keyword) {
		String o = offset + "", l = limit + "";
		if (offset < 0)
			o = "0";
		if (limit <= 0)
			l = "10";
		return Constants.API_MELON_SEARCH_INTEGRATION_SONG + "?offset=" + o
				+ "&limit=" + l + "&keyword=" + keyword;
	}

	public static String getSearchIntegrationAlbum(int offset, int limit,
			String keyword) {
		String o = offset + "", l = limit + "";
		if (offset < 0)
			o = "0";
		if (limit <= 0)
			l = "10";
		return Constants.API_MELON_SEARCH_INTEGRATION_ALBUM + "?offset=" + o
				+ "&limit=" + l + "&keyword=" + keyword;
	}

	// user registration

	// album section

	public static String getAlbumByArtist(int offset, int limit, String dir,
			int artistId) {
		String o = offset + "", l = limit + "";
		if (offset < 0)
			o = "0";
		if (limit <= 0)
			l = "10";
		return Constants.API_MELON_ALBUM_BY_ARTIST + "?artistId=" + artistId
				+ "&offset=" + o + "&limit=" + l + "&dir=" + dir;
	}

	public static String getAlbumByGenreId(int offset, int limit, String dir,
			int genreId) {
		String o = offset + "", l = limit + "", g = genreId + "";
		if (offset < 0)
			o = "0";
		if (limit <= 0)
			l = "10";
		if (genreId < 0)
			g = "null";
		return Constants.API_MELON_ALBUM_BY_GENRE + "?genreId=" + g
				+ "&offset=" + o + "&limit=" + l + "&dir=" + dir;
	}

	public static String getAlbumByNewestAlbum(int offset, int limit,
			String dir, int genreId) {
		if (genreId <= 0)
			return Constants.API_MELON_ALBUM_NEW + "?genreId=" + "null"
					+ "&offset=" + offset + "&limit=" + limit + "&dir=" + dir;
		return Constants.API_MELON_ALBUM_NEW + "?genreId=" + genreId
				+ "&offset=" + offset + "&limit=" + limit + "&dir=" + dir;
	}

	public static String getAlbumByHottestAlbum(int limit, int genreId) {
		String l = limit + "", g = genreId + "";
		if (limit <= 0)
			l = "null";
		if (genreId <= 0)
			g = "null";

		return Constants.API_MELON_ALBUM_HOT + "?limit=" + l + "&genreId=" + g;
	}

	public static String getAlbumByAlbumId(int albumId) {
		return Constants.API_MELON_ALBUM_BY_ALBUM_ID + albumId;
	}

	// artist section

	public static String getArtistByArtistId(int artistId) {
		return Constants.API_MELON_ARTIST_DETAILS + "/" + artistId;
	}

	public static String getArtistByHottestArtist(int limit) {
		String l = limit + "";
		if (limit <= 0)
			l = "6";
		return Constants.API_MELON_ARTIST_HOT + "?limit=" + l;
	}

	// song section
	public static String getSongByAlbum(int offset, int limit, String albumId) {
		String o = offset + "", l = limit + "";
		if (offset < 0)
			o = "0";
		if (limit < 1)
			l = "10";
		return Constants.API_MELON_SONG_BY_ALBUM + "?offset=" + o + "&limit="
				+ l + "&albumId=" + albumId;
	}

	public static String getSongByArtist(int offset, int limit, String artistId) {
		String o = offset + "", l = limit + "";
		if (offset < 0)
			o = "0";
		if (limit < 1)
			l = "10";
		return Constants.API_MELON_SONG_BY_ARTIST + "?offset=" + o + "&limit="
				+ l + "&artistId=" + artistId;
	}

	public static String getSongByGenre(int offset, int limit, String genreId) {
		String o = offset + "", l = limit + "";
		if (offset < 0)
			o = "0";
		if (limit < 1)
			l = "10";
		return Constants.API_MELON_SONG_BY_GENRE + "?offset=" + o + "&limit="
				+ l + "&genreId=" + genreId;
	}

	public static String getSongByNewSong(int offset, int limit,
			Enumerations.Dir dir, String genreId) {
		String o = offset + "", l = limit + "", d = null;
		if (dir == Dir.ASC)
			d = "asc";
		else if (dir == Dir.DESC)
			d = "desc";
		else
			d = "desc";
		if (offset < 0)
			o = "0";
		if (limit < 1)
			l = "10";
		return Constants.API_MELON_SONG_BY_NEW + "?offset=" + o + "&limit=" + l
				+ "&dir=" + d + "&genreId=" + genreId;
	}

	// genre section

	public static String getGenreByCategories() {
		return Constants.API_MELON_GENRE_CATEGORIES;
	}

	public static String getGenreByGenreId(String genreId) {
		String url = Constants.API_MELON_GENRE_CATEGORIES_BY_ID;
		return url + "/" + genreId + "/genres";
	}

	public static String getGenreByAllGenres() {
		return Constants.API_MELON_GENRE_CATEGORIES_ALL;
	}

	// purchase section

	// certification section

	public static String getCertification(String userId, String songId,
			String type, String channelCd) {
		return Constants.API_MELON_CERTIFICATE + "?userId=" + userId
				+ "&songId=" + songId + "&channelCd=" + channelCd
				+ "&contentType=" + type;
	}

}
